package com.mceil.mceilbase.activity;

import android.content.Intent;
import android.view.View;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.mceil.mceilbase.R;
import com.mceil.mceilbase.adapter.MainAdapter;
import com.mceil.mceilbase.bean.MainBean;
import com.mceil.mylibrary.annotation.ContentView;
import com.mceil.mylibrary.annotation.ViewInject;
import com.mceil.mylibrary.base.BaseActivity;

import java.util.ArrayList;
import java.util.List;

import es.dmoral.toasty.Toasty;
import tech.gujin.toast.ToastUtil;


@ContentView(R.layout.activity_main)
public class MainActivity extends BaseActivity {
    @ViewInject(R.id.recycleView)
    RecyclerView recyclerView;

    @ViewInject(R.id.con_top)
    ConstraintLayout conTop;

    @Override
    protected void initPreferences() {

    }

    @Override
    protected void initView() {
        conTop.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(mContext, "哈哈哈哈", Toast.LENGTH_SHORT).show();
                Toasty.success(mContext,"成功提交").show();
            }
        });
    }

    @Override
    protected void initData() {


        List<MainBean> mDatas= new ArrayList<>();

        mDatas.add(new MainBean("日常记录",R.drawable.icon_daliy,"日常记录",1));

        mDatas.add(new MainBean("待建功能",R.drawable.icon_sub,"待建功能",2));

        mDatas.add(new MainBean("待建功能",R.drawable.icon_mu,"待建功能",3));

        mDatas.add(new MainBean("待建功能",R.drawable.icon_div,"待建功能",4));

        recyclerView.setLayoutManager(new GridLayoutManager(mContext,2));

        MainAdapter adapter = new MainAdapter(R.layout.item_main,mDatas);

        recyclerView.setAdapter(adapter);

        adapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
                Intent intent =null;

                switch (position){
                    case 0:
                        intent = new Intent(MainActivity.this,DaliyActivity.class);
                }
                startActivity(intent);
            }
        });
    }
}